package controller.user.order;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import service.Impl.OrderServiceImpl;
import util.ResultUtil;

import java.io.IOException;

@WebServlet("/user/order/cancel")
public class OrderCancelController extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int id=Integer.parseInt(req.getParameter("id"));
        String cancelReason=req.getParameter("cancelReason");
        OrderServiceImpl orderService = new OrderServiceImpl();
        orderService.cancel(id,cancelReason);
        String json= ResultUtil.getJSON(null);
        resp.getWriter().write(json);
    }
}
